package com.qianxun.init.listener;

import com.qianxun.framework.common.constant.SystemConstant;
import com.qianxun.init.properties.SpringServerProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;

import javax.annotation.Resource;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;


/**
 * 初始化监听器
 * @author: huwei
 * @date: 2019/10/18 15:26
 * @version: 1.0.0
 */
@Slf4j
@Order(-99)
@WebListener
public class SystemPropertiesListener implements ServletContextListener {

    @Resource
    private com.qianxun.init.properties.SysProperties sysProperties;

    @Resource
    private SpringServerProperties springServerProperties;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        log.info("--- 初始化系统常量开始 ---");
        SystemConstant.putAll(sysProperties.getMaps());
        SystemConstant.put("context-path" ,springServerProperties.contextPath());
        log.info("--- 初始系统常量完成 ---");
        SystemConstant.println();
    }

}
